package com.prs.crm.action.purchase.flow;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.flow.WorkFlowProcessNodeDetail;
import com.prs.crm.domain.purchase.FundsInBar;
import com.prs.crm.domain.purchase.PurchaseOrder;
import com.prs.crm.domain.purchase.PurchaseReturned;
import com.prs.crm.domain.purchase.PurchaseReturnedStoreOut;
import com.prs.crm.domain.purchase.PurchaseReturnedStoreOutDetail;
import com.prs.crm.service.purchase.FundsInBarService;
import com.prs.crm.service.purchase.PurchaseOrderService;
import com.prs.crm.service.purchase.PurchaseReturnedService;

/**
 * 审核流程
 * 
 * @author 兰小刚
 * @version 创建时间：2010-7-21 下午14:45:10 类说明
 */
@SuppressWarnings("serial")
public class PurchaseReturnedFlowAction extends FlowAction<PurchaseReturned> {

	private PurchaseReturned purchaseReturned;

	private PurchaseReturnedService purchaseReturnedService;

	private WorkFlowProcessNodeDetail detail;

	private PaginationSupport pagination;

	private FundsInBar fundsInBar;

	private PurchaseReturnedStoreOut purchaseReturnedStoreOut;

	private PurchaseReturnedStoreOutDetail purchaseReturnedStoreOutDetail;

	private FundsInBarService fundsInBarService;

	@Action("listReturnedPurchaseFlow")
	public String listReturnedPurchaseFlow() {
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination = this.getPurchaseReturnedService().listFlowTask(
				PurchaseReturned.class, pagination,
				AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}

	@Action("editReturnedPurchaseFlow")
	public String editReturnedPurchaseFlow() {
		this.displayEndNodes();
		return SUCCESS;
	}

	@Clew(results = { "success" })
	@Action(value = "submitPurchaseReturnedFlow", results = { @Result(name = "success", type = "redirect", location = "listReturnedPurchaseFlow") })
	public String submitPurchaseReturnedFlow() {
		this.getPurchaseReturnedService().execute(this.getNode(),
				this.getDetail(), purchaseReturned,
				AppContext.getAccountContext().currentUser());

		this.setPrompt("提交成功");
		return SUCCESS;
	}

	public PurchaseReturned getPurchaseReturned() {
		return purchaseReturned;
	}

	public void setPurchaseReturned(PurchaseReturned purchaseReturned) {
		this.purchaseReturned = purchaseReturned;
	}

	public PurchaseReturnedService getPurchaseReturnedService() {
		return purchaseReturnedService;
	}

	public void setPurchaseReturnedService(
			PurchaseReturnedService purchaseReturnedService) {
		this.purchaseReturnedService = purchaseReturnedService;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public WorkFlowProcessNodeDetail getDetail() {
		return detail;
	}

	public void setDetail(WorkFlowProcessNodeDetail detail) {
		this.detail = detail;
	}

	public FundsInBar getFundsInBar() {
		return fundsInBar;
	}

	public void setFundsInBar(FundsInBar fundsInBar) {
		this.fundsInBar = fundsInBar;
	}

	public PurchaseReturnedStoreOut getPurchaseReturnedStoreOut() {
		return purchaseReturnedStoreOut;
	}

	public void setPurchaseReturnedStoreOut(
			PurchaseReturnedStoreOut purchaseReturnedStoreOut) {
		this.purchaseReturnedStoreOut = purchaseReturnedStoreOut;
	}

	public PurchaseReturnedStoreOutDetail getPurchaseReturnedStoreOutDetail() {
		return purchaseReturnedStoreOutDetail;
	}

	public void setPurchaseReturnedStoreOutDetail(
			PurchaseReturnedStoreOutDetail purchaseReturnedStoreOutDetail) {
		this.purchaseReturnedStoreOutDetail = purchaseReturnedStoreOutDetail;
	}

	public FundsInBarService getFundsInBarService() {
		return fundsInBarService;
	}

	public void setFundsInBarService(FundsInBarService fundsInBarService) {
		this.fundsInBarService = fundsInBarService;
	}

}
